package com.four;

public class Box {
	private int apple=0;
	public synchronized void in() {
		while(apple==5) {
			try{
				wait();
			}catch(Exception e) {
				e.printStackTrace();
			}
		}
		apple++;
		notifyAll();
	}


public synchronized void out() {
	while(apple==0) {
		try{
			wait();
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
	apple--;
	notifyAll();
}
}